home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlibs.zip / STRNLEN.C < prev    next >
Text File  |  1993-01-04  |  459b  |  22 lines

  1.  
  2. /*  File   : strnlen.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 10 April 1984
  5.     Defines: strnlen()
  6.  
  7.     strnlen(src, len)
  8.     returns the number of characters up to the first NUL in src, or len,
  9.     whichever is smaller.  This is the same as strnend(src,len)-src.
  10. */
  11.  
  12. int strnlen(s, n)
  13.     register char *s;
  14.     register int n;
  15.     {
  16.         register int L;
  17.  
  18.         for (L = 0; --n >= 0 && *s++; L++) ;
  19.         return L;
  20.     }
  21.  
  22.